from Tools.do_excel import DoExcel
from Tools.TestHTTPRequest import HTTPRequest

Cookie = None
# 注册

def run(test_data, sheet_name):  # 传列表嵌套字典参�?
    global Cookie

    for i in range(len(test_data)):  # i�?0开�?
        # 从数据文件取值，输出title信息
        print(f"正在测试的用例是：{test_data[i]['title']}")
        # 执行请求，调用请求方法取�?
        login_res = HTTPRequest('https://openapiv5.ketangpai.com//UserApi/login',
                                '{"email": "790874262@qq.com", "password": "beiaidigan123!", "remember": "0"}').test_requests(
            test_data[i]['url'], test_data[i]['data'], test_data[i]['http_method'])
        # DoExcel().write_data("case_data/case_data.xlsx", "register", i + 2, str(login_res.json()))
        # 去掉写死sheet_name，改成实例化才传参，动态参�?
        DoExcel().write_data("case_data/case_data.xlsx", sheet_name, i + 2, str(login_res.json()))

        if login_res is not None:
            print(f"请求的结果是：{login_res.json()}")
        else:
            print("请求的结果为�?")



test_data = DoExcel().get_data("case_data/case_data.xlsx", 'createCourse')
run(test_data, 'createCourse')

